﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GQ.BLL.QuanLyKho;
using GQ.WinForms;
namespace GQ.QuanLyKho
{
    public partial class frmChiNhanh : frmBase
    {
        public ChiNhanh ChiNhanh;
        ValidateCollection _validates = new ValidateCollection();
        public frmChiNhanh()
        {
            InitializeComponent();
            _validates.Add(new ValidateEmpty(txtMa, "Mã không được để trống", dxErrorProvider1));
            _validates.Add(new ValidateEmpty(txtTen, "Tên không được để trống", dxErrorProvider1));

        }

        private void SetData()
        {
            txtMa.Text = ChiNhanh.Ma;
            txtTen.Text = ChiNhanh.Ten;
            txtGhiChu.Text = ChiNhanh.GhiChu;
        }
        private void GetData()
        {
            ChiNhanh.Ma = txtMa.Text;
            ChiNhanh.Ten = txtTen.Text;
            ChiNhanh.GhiChu = txtGhiChu.Text;
        }

        private void frmChiNhanh_Load(object sender, EventArgs e)
        {
            SetData();
        }

        private void btnSave_CheckedChanged(object sender, EventArgs e)
        {
            if (!_validates.Validate()) return;
            GetData();
            ChiNhanh.Save();
            DialogResult = DialogResult.OK;
        }

        private void btnClose_CheckedChanged(object sender, EventArgs e)
        {
            this.Close();
        }


    }
}
